package org.huawei260.TiKu.ODsuanfa;

import java.util.HashMap;
import java.util.Scanner;
/**
 * @Author: qingle
 * @Date: 2024/10/28-16:11
 * @Description: 2562 【排序】2024E字符统计及重排
 * @version: 1.0
 */
public class E_2024E_2562__排序字符统计及重排 {


//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			String s = sc.nextLine();
			System.out.println(getResult(s));
		}

		public static String getResult(String s) {
			HashMap<Character, Integer> letter = new HashMap<>();

			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				letter.put(c, letter.getOrDefault(c, 0) + 1);
			}

			StringBuilder sb = new StringBuilder();

			letter.entrySet().stream()
				.sorted(
					(a, b) -> {
						if (a.getValue() - b.getValue() != 0) {
							return b.getValue() - a.getValue();
						} else {
							if ((isLower(a.getKey()) && isLower(b.getKey()))
								|| (isUpper(a.getKey()) && isUpper(b.getKey()))) {
								return a.getKey() - b.getKey();
							} else {
								if (isUpper(a.getKey())) return 1;
								else return -1;
							}
						}
					})
				.forEach(entry -> sb.append(entry.getKey() + ":" + entry.getValue() + ";"));

			return sb.toString();
		}

		public static boolean isLower(char letter) {
			return letter >= 'a' && letter <= 'z';
		}

		public static boolean isUpper(char letter) {
			return letter >= 'A' && letter <= 'Z';
		}
	}